fix(igdb): don't match series games to their base title#3817
Merged
Conversation
Series titles like "Metal Gear Solid: Portable Ops Plus" and the Pokemon Ranger games were resolved to the same IGDB (and, downstream, SteamGridDB) entry as their base game, so distinct ROMs became siblings. The first `_search_rom` pass filters by game_type, which excludes types like EXPANSION, so a more specific variant is often absent from its candidates. Jaro-Winkler scores the base title against the searched variant at ~0.99 (well above the 0.75 threshold), so the base was accepted and returned before the broader search passes ran. Only trust a first-pass hit outright when it is an exact match or not a prefix/superset near-miss of the search term. Otherwise widen the search: re-query without the game_type filter (the reliable recovery for excluded types) alongside the existing expanded search, then re-rank across the union so an exact variant outranks the base near-miss. The base stays in the pool, so it remains the fallback when no better match exists. Fixes #3805 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR broadens IGDB matching when a first-pass result is a prefix near-match. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix(igdb): don't match series games to t..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Explain the changes or enhancements you are proposing with this pull request.
Fixes #3805 (a recurrence of #3309, only partially addressed by #3400).
Series titles like Metal Gear Solid: Portable Ops Plus / Portable Ops and the Pokémon Ranger games were resolved to the same IGDB id, and therefore the same SteamGridDB id, as their base game, so distinct ROMs ended up as siblings. Hasheous and RetroAchievements (hash-based) matched them correctly; only the name-search providers were wrong.
Root cause
IGDBHandler._search_romruns a first pass filtered bygame_type(MAIN_GAME, EXPANDED_GAME, PORT, REMAKE, REMASTER, STANDALONE_EXPANSION), which excludes types likeEXPANSION. So a more specific variant is frequently absent from that pass's candidates. Jaro-Winkler scores the base title against the searched variant very high for prefix/superset titles (measured with the repo's own matcher:portable ops plusvsportable ops= 0.9928; Pokémon Ranger variants ≈ 0.90–0.91), all far above the 0.75 match threshold. The base was therefore accepted and returned before the broader search passes ever ran. SteamGridDB then inherited the wrong title becausefetch_sgdb_detailsseeds its search from the IGDB name first.Fix
_is_prefix_superset_match()to detect when one title's words are a proper prefix of the other's.game_typefilter (the reliable recovery, since the variant is often an excluded type) alongside the existing expanded/searchpass, then re-rank across the union so an exact variant (score 1.0) outranks the base near-miss (0.99). The base stays in the candidate pool, so it remains the fallback when no better match exists.The gate keeps this cheap: exact matches and ordinary fuzzy matches still return on the first pass with no extra API calls; only genuine prefix ambiguity triggers widening.
AI assistance disclosure
Per
CONTRIBUTING.md: this change was written with AI assistance (Claude Code / Opus 4.8). The diagnosis, implementation, and tests were AI-generated and human-reviewed.Checklist
Please check all that apply.
Full metadata test suite (321 tests) passes, including 9 new tests covering the prefix heuristic and the
_search_romwidening/no-widen paths.trunk check(ruff/black/isort/mypy) clean.Screenshots (if applicable)
N/A (backend metadata-matching change)
🤖 Generated with Claude Code